<template>
  <a-drawer :visible="openView" width="35%" @close="onCloseView">
    <template slot="title">
      <b>{{ form.nickName }}的信息</b>
    </template>
    <a-descriptions layout="vertical" bordered :column="2">
      <a-descriptions-item label="姓名">
        {{ form.nickName }}
      </a-descriptions-item>
      <a-descriptions-item label="学号">
        {{ form.userName }}
      </a-descriptions-item>
      <a-descriptions-item label="性别">
        {{ sexFormat(form.sex) }}
      </a-descriptions-item>
      <a-descriptions-item label="手机">
        {{ form.phonenumber }}
      </a-descriptions-item>
      <a-descriptions-item label="班级">
        {{ form.className }}
      </a-descriptions-item>
      <a-descriptions-item label="专业">
        {{ form.specialtyName }}
      </a-descriptions-item>
      <a-descriptions-item label="创建时间">
        {{ form.createTime }}
      </a-descriptions-item>
      <a-descriptions-item label="更新时间">
        {{ form.updateTime }}
      </a-descriptions-item>
      <a-descriptions-item label="备注" >
        {{ form.remark ? form.remark : '-' }}
      </a-descriptions-item>
    </a-descriptions>
  </a-drawer>
</template>

<script>

import { getStudent } from '@/api/platform/student'

export default {
  name: 'ViewForm',
  props: {
    sexOptions: {
      type: Array,
      required: true
    }
  },
  data () {
    return {
      loading: false,
      formTitle: '',
      // 表单参数
      form: {
        studentId: undefined,
        nickName: undefined,
        userName: undefined,
        phonenumber: undefined,
        sex: undefined,
        classId: undefined,
        specialtyId: undefined,
        className: undefined,
        specialtyName: undefined,
        remark: undefined,
        createTime: undefined,
        updateTime: undefined
      },
      openView: false
    }
  },
  filters: {},
  created () {
  },
  computed: {},
  watch: {},
  methods: {
    // 性别格式化
    sexFormat (sex) {
      return this.selectDictLabel(this.sexOptions, sex)
    },
    /** 根据id查询数据 */
    handleView (row) {
      getStudent(row.studentId).then(response => {
        this.form = response.data
        this.openView = true
      })
    },
    // 关闭弹框
    onCloseView () {
      this.openView = false
    }
  }
}
</script>
<style>
.ant-card-head {
  border-bottom: 0px solid #e8e8e8 !important;
}
</style>
